package com.the9tcat.everydayapp.widget;

import com.the9tcat.everydayapp.AppDetailActivity;
import com.the9tcat.everydayapp.R;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class AppWidgetSmall extends AppWidgetProvider {

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		super.onUpdate(context, appWidgetManager, appWidgetIds);
        int len = appWidgetIds.length;
        for (int i = 0; i < len; i++) {
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_small_layout);
            Intent in = new Intent(context, AppDetailActivity.class);
            PendingIntent pi = PendingIntent.getActivity(context, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
            views.setOnClickPendingIntent(R.id.layout, pi);
            appWidgetManager.updateAppWidget(appWidgetIds[i], views);
        }
	}

	@Override
	public void onDeleted(Context context, int[] appWidgetIds) {
		super.onDeleted(context, appWidgetIds);
	}

	@Override
	public void onDisabled(Context context) {
		super.onDisabled(context);
	}

	@Override
	public void onEnabled(Context context) {
		super.onEnabled(context);
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		super.onReceive(context, intent);
	}
}
